#!/usr/bin/perl -w
use strict;

my %px_phone_num;
open IN, 'peixun.txt';
while (<IN>) {
	chomp;
	next if (length() < 5);
	$px_phone_num{$_} = 0;
}
close IN;

my ($phone_num, $time, %keywords);
while (<>) {
	chomp;
	my @arr = split("\t");
	next if (@arr != 7);
	next if (defined($px_phone_num{$arr[0]}));
	if (defined($phone_num) && $phone_num != $arr[0]) {
		output_phone_num();
		%keywords = ();
	}
	$phone_num = $arr[0];
	$time = $arr[6];
	for (my $i = 1; $i < 6; ++$i) {
		last if ($arr[$i] eq 'NULL');
		$keywords{$arr[$i]} = 0;
	}
}

sub output_phone_num {
	print $phone_num;
	foreach my $keyword (keys %keywords) {
		print "\t$keyword";
	}
	print "\t$time\n";
}
